package com.pocket.insight.base.sql.visitor;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.pocket.insight.base.sql.visitor.common.AddDbPrefixCommonVisitor;
import com.pocket.insight.base.sql.visitor.oracle.AddDbPrefixOracleVisitor;
import com.pocket.insight.base.sql.visitor.sqlserver.AddDbPrefixSqlserverVisitor;

/**
 * 描述：
 *
 * @author shuize
 * @create 2024/12/14
 */
public class AddDbPrefixVisitorFactory {
    public AddDbPrefixVisitorFactory() {
    }

    public static SQLASTVisitor build(DbType dbType, String tablePrefix) {
        if (dbType == DbType.oracle) {
            return new AddDbPrefixOracleVisitor(tablePrefix);
        } else {
            return dbType == DbType.sqlserver ? new AddDbPrefixSqlserverVisitor(tablePrefix) : new AddDbPrefixCommonVisitor(tablePrefix);
        }
    }
}
